import custom_mouse
import custom_xinput

k = 1.0  # 缩放因子
user_index = 0  # 使用第一个控制器

is_activated = False
before_buttons = False
while True:
    ret, state = custom_xinput.get_state(user_index)
    now_buttons = state.Gamepad.wButtons
    if before_buttons == False and now_buttons == 1: # 按下十字键上键
        is_activated = not is_activated
    before_buttons = now_buttons

    if is_activated:
        custom_mouse.move_mouse_to_stick(k*state.Gamepad.sThumbRX, k*state.Gamepad.sThumbRY)